﻿using System;


namespace DiscoveryLogic.DataServices.DataSources
{
    public class Child
    {
        #region Private Variables

            public enum CollegeType{InState, OutOfState, Private};

            private string fullName = "";
            private string firstName = "";
            private int age = 0;
            private double initialInvestment = 0;
            private CollegeType collegeType = CollegeType.InState;
            private string collegeTypeString = "";
            private double costOfCollege = 0;
            private double monthlyContribution = 0;

        #endregion

        #region Constructors

            public Child()
            {
            }

        #endregion

        #region Get/Set Properties

            public string FullName
            {
                get { return fullName; }
                set 
                { 
                    fullName = value; 

                    // Parse out first name
                    int i = fullName.IndexOf(" ");
                    if (i > 0)
                    {
                        firstName = fullName.Substring(0, i);
                    }
                    else
                    {
                        firstName = fullName;
                    }
                }
            }

            public string FirstName
            {
                get { return firstName; }
                set { firstName = value; }
            }        

            public int Age
            {
                get { return age; }
                set { age = value; }
            }

            public double InitialInvestment
            {
                get { return initialInvestment; }
                set { initialInvestment = value; }
            }

            public CollegeType AttendingCollegeType
            {
                get { return collegeType; }
                set 
                { 
                    collegeType = value;

                    if (collegeType == Child.CollegeType.InState)
                    {
                        costOfCollege = 80500;
                        CollegeTypeString = "In-State";
                    }
                    else if (collegeType == Child.CollegeType.OutOfState)
                    {
                        costOfCollege = 120500;
                        CollegeTypeString = "Out-Of-State";
                    }
                    else
                    {
                        costOfCollege = 185000;
                        CollegeTypeString = "Private";
                    }
                }
            }

            /// <summary>
            /// College type formatted in a nice string
            /// </summary>
            public string CollegeTypeString
            {
                get { return collegeTypeString; }
                set { collegeTypeString = value; }
            }

            public double CostOfCollege
            {
                get { return costOfCollege; }
                set { costOfCollege = value; }
            }

            public double MonthlyContribution
            {
                get { return monthlyContribution; }
                set { monthlyContribution = Math.Round(value); }
            }

        #endregion
    }
}
